<?php defined('SYSPATH') OR die('No direct access allowed.');  ?>
<div>
    <?
        print html::script(array(
            'media/js/mootools.js',
            'media/js/DatePicker.js',
            'media/js/mootime.js',
            'media/js/Validator.js',
            ));
        
        print html::stylesheet(array(
             'media/css/DatePicker.css',
             'media/css/mootime.css',
             ));
                
    ?>



<script type="text/javascript">
// The following should be put in your external js file,
// with the rest of your ondomready actions.
//var edit_event;
window.addEvent('domready', function(){  
    $$('input.DatePicker').each( function(el){
        new DatePicker(el);
    });
    $$('input.mootime').each(function(el){
        mootime(el.id);
    });
   new Validator('edit_event', {immediate : true, useTitles : true} );
});
</script>
    <form id="edit_event" name="edit_event" method="post" action="/event/save">
        <style type="text/css">
        .label{
            text-align: right;
        }
        .editor{
            text-align: center;
            margin:auto;
        }
        .editor td{
            text-align: left;
        }
        </style>
        <span style="font-size: larger; color: red;" id='error_message' name='error_message'>
            <? echo isset($error_message)?$error_message:''; ?>
        </span>
        <? print form::hidden('event_id', $form['event_id'])?>
        <table class="editor">
            <tr>
                <td class="label"><? print form::label('name', 'Event Name:')?></td>
                <td> <? print form::input(array('maxlength'=>255, 'name'=>'name', 'class'=>'required', 'title'=>'Enter event name'), $form['name']) ?></td>
            </tr>
            <tr>
                <td class="label"><? print form::label('keywords', 'Keywords:')?></td>
                <td> <input type="text" name="keywords" id="keywords" /> </td>
            </tr>
            <tr>
                <td class="label"><? print form::label('network', 'Network:')?></td>
                <td> <select name="network" id="network"></select></td>
            </tr>
            <tr>
                <td class="label"><? print form::label('scope', 'Scope:')?></td>
                <td> <?print form::dropdown('scope',array('P'=>'Private', 'R'=>'Restricted', 'G'=>'Global'), $form['scope']) ?></td>
            </tr>
            <tr>
                <td class="label"><? print form::label('host_name', 'Host Name:')?></td>
                <td> <?print form::input('host_name', $form['host_name'])?></td>
            </tr>            
            <tr><td></td><td><hr></td></tr>
            <tr> 
                <td class="label"> <? print form::label('description', 'Description:')?></td>
                <td> <? print form::textarea(array('name'=>'description', 'rows'=>'5', 'cols'=>'30'), $form['description']) ?> </td>
            </tr>
            <tr> 
                <td class="label"> <? print form::label('start_date', 'Start Time:')?></td>
                <td> 
                    <? print form::input(array('name'=>'start_date', 'class'=>'DatePicker'),Date('m/d/Y',$form['start_time'])) ?>
                    <? print form::input(array('name'=>'start_time', 'class'=>'mootime', 'size'=>'10'), Date('h:i A', $form['start_time'])) ?>
                </td>
            </tr>
            <tr> 
                <td class="label"> <? print form::label('end_date', 'End Time:')?></td>
                <td> 
                    <? print form::input(array('name'=>'end_date', 'class'=>'DatePicker'),Date('m/d/Y',$form['end_time'])) ?>
                    <? print form::input(array('name'=>'end_time', 'class'=>'mootime', 'size'=>'10'), Date('h:i A', $form['end_time'])) ?>
                </td>
            </tr>
            <tr>
                <td class="label"> <? print form::label('street', 'Street:')?></td>
                <td><? print form::input('street', $form['street']) ?> </td>
            </tr>
            <tr>
                <td class="label"> <? print form::label('city', 'City:')?></td>
                <td><? print form::input('city', $form['city']) ?></td>
            </tr>
            <tr>
                <td class="label"> <? print form::label('state', 'State:')?></td>
                <td>
                    <? print form::dropdown('state',array('MD'=>'MD','MA'=>'MA','NY'=>'NY'), $form['state']) ?>
                </td>
            </tr>
            <tr>
                <td class="label"> <? print form::label('zip_code', 'Zip Code:')?></td>
                <td> <? print form::input(array('name'=>'zip_code','maxlength'=>'5', 'style'=>'width:40px'), $form['zip_code']) ?></td>
            </tr>
            <tr><td></td><td><hr></td></tr>    
            <tr>
                <td class="label"> <? print form::label('phone', 'Phone:')?></td>
                <td> <? print form::input('phone', $form['phone']) ?> </td>
            </tr>
            <tr>
                <td class="label"> <? print form::label('email', 'Email:')?></td>
                <td>  <? print form::input(array('name'=>'email', 'class'=>'validate-email'), $form['email']) ?> </td>
            </tr>   
            <tr>
                <td></td>
                <td>
                    <?
                        print form::input(array('type'=>'submit', 'name'=>'save_event'),$form['event_id']==null?"Create Event":"Save Event");
                        print form::input(array('type'=>'button', 'name'=>'cancel'), 'Cancel');
                    ?>
                </td>
            </tr>
        </table>
    </form>  
</div>